from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView
from goods.models import GoodsChannel, GoodsChannelGroup
from meiduo_admin.serializers.channel_serializers import GoodsChannelSerializer, GoodsChannelGroupSerializer
from meiduo_admin.utils import MyPagination


class ChannelView(ModelViewSet):
    """ 商品频道表 增删改查 """

    queryset = GoodsChannel.objects.all().order_by("id")
    serializer_class = GoodsChannelSerializer
    pagination_class = MyPagination


class ChannelGroupView(ListAPIView):
    """ 获取商品频道分组信息 """

    queryset = GoodsChannelGroup.objects.all()
    serializer_class = GoodsChannelGroupSerializer
    pagination_class = None
